Title: Remove the Attribute From the Product Title

Publish Date: Thu, 01 Jun 2017 07:00:00 +0000

Categories: Uncategorized

Content:

In a recent version of [ablank href="https://woocommerce.com/"]WooCommerce[/ablank] the developers made a tweak to how variable products are show when they only have one attribute. The chose attribute value is shown directly in the product title when, in example, the product is added to the cart.

I’ve noticed that not everyone likes this new feature and some asked to revert it back to how it was before.

Can we accommodate everyone? Yes, here is how.



Let's Write Some Code!

I created a [ablank href="https://github.com/woocommerce/woocommerce/pull/14556"]Pull Request[/ablank] not too long ago to add the filter woocommerce_is_attribute_in_product_name to the core of WooCommerce.

This filter can be used to show the attributes below the product title, like it was before the most recent version of WooCommerce.

You can add this code to the functions.php file in wp-content/themes/your-child-theme-name/ to do that:

https://gist.github.com/85ff518658e4e07476deca0616084e58

This code alone though is not enough. You will now see the attributes table below the product title, but also you will see the attribute in the product title.

To remove it from there, you need some more code:

https://gist.github.com/506d631edf97202873aaf5fecbc138fc

Using both these snippets together will make sure that you only show the attributes table like it was before, and the title of the product will be the one that you set in the Dashboard, with nothing added to it.
